﻿using Microsoft.AspNetCore.Http;
using System;
using System.Collections.Generic;
using System.Text;

namespace Ruanmou.Comm.Extend
{
    /// <summary>
    /// HttpRequest扩展类
    /// </summary>
    public static class HttpRequestExtensions
    {
        /// <summary>
        /// 判断当前请求是否为Ajax请求
        /// </summary>
        /// <param name="httpRequest"></param>
        /// <returns>Ajax请求则为true，非Ajax请求则为false</returns>
        public static bool IsAjaxRequest(this HttpRequest httpRequest) => "XMLHttpRequest".Equals(httpRequest.Headers["X-Requested-With"]);
    }
}
